Sensor devices and methods for calculating an orientation while accounting for magnetic interference

ABSTRACT

Sensor devices and methods for calculating an orientation of a sensor device including a magnetometer are disclosed. In one embodiment, a method of computing an orientation of a sensor device includes receiving a current magnetic field reading including at least a magnetic field magnitude, calculating a difference between the current magnetic field magnitude and a reference magnetic field magnitude, and comparing the difference between the current magnetic field magnitude and the reference magnetic field magnitude with a threshold. The method further includes adjusting a trust value of the magnetometer such that the trust value is decreased if the difference between the current magnetic field magnitude is greater than or equal to the threshold, and computing an orientation of the sensor device based at least on the trust value and the current magnetic field reading, wherein the trust value affects a reliance on the magnetic field reading in computing the orientation.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Patent App. No.PCT/US2014/049895, entitled “Sensor Devices And Method For CalculatingAn Orientation While Accounting For Magnetic Interference,” filed Aug.6, 2014, which claims the benefit of U.S. Provisional Patent ApplicationSer. No. 61/862,699, entitled “Detecting Interference In MagnetometerMeasurements To Determine Confidence In Sensor,” filed Aug. 6, 2013, theentire disclosures of which are hereby incorporated herein by reference.

TECHNICAL FIELD

The present application relates to sensor device and, more particularly,sensor devices and methods for calculating an orientation that accountfor magnetic interference.

SUMMARY OF INVENTION

Many systems incorporate sensors to measure directional physicalquantities. Such sensors may include, but are not limited to, multi-axismagnetometers, multi-axis accelerometers, sonar arrays, radar arrays,and the like.

However, sensors can exhibit inaccuracies stemming from a variety ofsources. For example, a multi-axis magnetometer may exhibit inaccuraciesfrom imperfections in the sensor itself (scale/bias, sensornon-linearity, cross-axis effect, etc.), as well as from magnetic fielddistortion due to soft-iron effects of nearby ferrous system componentsor hard-iron effects of nearby magnetic sources such as motors,speakers, current carrying conductors, and the like. Magneticinterference from such sources can substantially reduce the accuracy ofthe magnetometer output. In such cases, it may be useful to rely moreheavily or fully on the other sensors provided within the sensor device.

FIGS. 1A-1C illustrate a moving sensor device 100 that passes near amagnetic field source 190 that generates a magnetic field 192. For mostorientation sensing applications wherein the sensor device includes oneor more accelerometers, one or more gyroscopes and one or moremagnetometers, it may be ideal to use all of the sensors of the sensordevice 100 when the sensor device 100 of FIG. 1A is outside of themagnetic field generated by source 102. Use of all of the sensors of thesensor device 100 may provide more information and allow a higher degreeof accuracy. However, when inside a magnetic field 192 as illustrated inFIG. 1B, as described in more detail herein, the magnetic field readingsdetected by the magnetometer of the sensor device 100 may be corruptedby the magnetic fields 192 such that the sensor device 100 may no longeraccurately detect the Earth's magnetic fields. When the sensor device100 passes completely by the magnetic source 190 and the magnetic field192 as shown in FIG. 1C, its readings may no longer be influencedsignificantly by the magnetic field 192.

It may be beneficial to trust the information from the magnetometerless, and to only have a high trust in the sensors which are notaffected by such magnetic fields 192 when the sensor device is within amagnetic field as illustrated in FIG. 1B. Further, it may also bebeneficial to switch back to using all sensors of the sensor device 100when the instrument moves back out of the magnetic field 192 asillustrated in FIG. 1C.

Sensor devices may utilize a filter, such as a Kalman filter, togenerate an output. Many such filters have a parameter indicating howmuch magnetometer readings should influence the output. This influenceis referred to herein as a trust level, T. The trust level T may rangefrom a minimum value to a maximum value. In one embodiment, the minimumtrust value is zero and the maximum trust value is one, with oneindicating that the magnetometer values are totally trusted, and zeroindicating the magnetometer values should not be used at all whencomputing the output. It should be understood that the trust levelconcepts described herein are for illustration, and the actual filterparameter this represents may not range from zero to one.

Embodiments of the present disclosure improve accuracies of sensordevices despite the influence of external magnetic fields by comparingcurrent magnetic field magnitudes with a reference magnetic fieldmagnitude. A trust value with respect to the readings of themagnetometer is decreased when a difference between the current magneticfield magnitude and the reference magnetic field magnitude is greaterthan a threshold such that the magnetometer is trusted less wheninfluenced by a magnetic field. The trust value may be increasedfollowing a waiting period wherein the difference between the currentmagnetic field magnitude and the reference magnetic field magnitude isless than the threshold.

In one embodiment, a sensor device, a sensor device includes amagnetometer operable to produce a magnetic field reading including atleast a magnitude of a magnetic field, a processor, wherein theprocessor is communicatively coupled to the magnetometer, and anon-transitory computer-readable memory storing instructions. Theinstructions, when executed by the processor, cause the processor toreceive a current magnetometer reading including at least a currentmagnetic field magnitude as detected by the magnetometer, calculate adifference between the current magnetic field magnitude and a referencemagnetic field magnitude, compare the difference between the currentmagnetic field magnitude and the reference magnetic field magnitude witha threshold, adjust a trust value of the magnetometer such that thetrust value is decreased if the difference between the current magneticfield magnitude is greater than or equal to the threshold, compute anorientation of the sensor device based at least on the trust value andthe current magnetic field reading, wherein the trust value affects areliance on magnetic field readings in computing the orientation of thesensor device, and provide an output signal, wherein the output signalindicates the orientation of the sensor device.

In another embodiment, a method of computing an orientation of a sensordevice includes receiving a current magnetic field reading including atleast a magnetic field magnitude as detected by a magnetometer,calculating a difference between the current magnetic field magnitudeand a reference magnetic field magnitude, and comparing the differencebetween the current magnetic field magnitude and the reference magneticfield magnitude with a threshold. The method further includes adjustinga trust value of the magnetometer such that the trust value is decreasedif the difference between the current magnetic field magnitude isgreater than or equal to the threshold, and computing an orientation ofthe sensor device based at least on the trust value and the currentmagnetic field reading, wherein the trust value affects a reliance onthe magnetic field reading in computing the orientation of the sensordevice.

BRIEF DESCRIPTION OF THE DRAWINGS

It is to be understood that both the foregoing general description andthe following detailed description describe various embodiments and areintended to provide an overview or framework for understanding thenature and character of the claimed subject matter. The accompanyingdrawings are included to provide a further understanding of the variousembodiments, and are incorporated into and constitute a part of thisspecification. The drawings illustrate various embodiments describedherein, and together with the description serve to explain theprinciples and operations of the claimed subject matter.

FIG. 1A schematically depicts a sensor device approaching a magneticfield source;

FIG. 1B schematically depicts a sensor device within a magnetic fieldproduced by the magnetic field source depicted in FIG. 1A;

FIG. 1C schematically depicts a sensor device leaving a magnetic fieldproduced by the magnetic field source depicted in FIGS. 1A and 1B;

FIG. 2 schematically depicts an example sensor device according to oneor more embodiments described and illustrated herein; and

FIGS. 3A and 3B schematically depict an example method for calculatingan orientation of a sensor device according to one or more embodimentsdescribed and illustrated herein.

DESCRIPTION OF EMBODIMENTS

Embodiments of the present disclosure are directed to sensor devices andmethods for computing an orientation of a sensor device that accountsfor the presence of magnetic fields. When an external magnetic field isproximate the sensor device and interferes with a magnetometer of thesensor device, the magnetometer is trusted less when computing theorientation of the sensor device. When no external magnetic field isproximate the sensor device, the magnetometer may be fully trusted. Morespecifically, a current magnetic field magnitude is compared to areference magnetic field magnitude, which commonly corresponds to themagnitude of the Earth's magnetic field in the geographic location ofthe sensor device, but could correspond to any given local magneticfield. A trust value associated with the magnetometer is lowered whenthe difference between the current magnetic field magnitude and areference magnetic field magnitude is greater than a threshold, such aswhen an external magnetic field is proximate the sensor device. In sucha manner, the magnetometer is trusted less when the sensor device is inthe presence of an external magnetic field. The trust value associatedwith the magnetometer may be increased if the difference between currentmagnetic field magnitude and the reference magnetic field magnitude isless than the threshold for a predetermined period of time. Varioussensor device and methods for computing an orientation of a sensordevice are described in detail below.

Referring now to FIG. 2, internal components of an exemplary sensordevice (e.g., the sensor device 100 depicted in FIGS. 1A-1C) isschematically illustrated. More particularly, FIG. 2 depicts a sensordevice 100 for estimating an orientation of the sensor device 200(and/or the orientation of an object or device incorporating the sensordevice 200) embodied as hardware, software, and/or firmware, accordingto embodiments shown and described herein. It is noted thatcomputer-program products and methods for correcting the output of thesensor device 200 may be executed by any combination of hardware,software, and/or firmware.

The sensor device 100 illustrated in FIG. 2 comprises a processor 102, anon-transitory computer-readable memory 104 (which may store computerreadable instructions (i.e., software code) for performing the variousfunctionality described herein, such as computing orientation of thesensor device, for example), at least one magnetometer 110 (e.g., amulti-axis magnetometer), at least one gyroscope 106 (e.g., a multi-axisgyroscope sensor), and at least one accelerometer 108 (e.g. a multi-axisaccelerometer sensor). Each of the illustrated components may becommunicatively coupled to the processor 102 (e.g., by a communicationbus,) which may be configured as any processor, micro-controller, or thelike, capable of executing computer readable instructions stored in thememory 104 or otherwise provided as software and/or firmware.

More or fewer sensors may be utilized. In the embodiments describedherein, only a single magnetometer 110 is required. Any combination ofany number of magnetometers 110, accelerometers 108 and gyroscopes 106may be provided within the sensor device 100. For example, the sensordevice 200 may include only one sensor. It should be understood that thecomponents illustrated in FIG. 2 are merely exemplary and are notintended to limit the scope of this disclosure.

The non-transitory computer-readable memory 104 may be configured asnonvolatile computer readable medium and, as such, may include randomaccess memory (including SRAM, DRAM, and/or other types of random accessmemory), flash memory, registers, compact discs (CD), digital versatilediscs (DVD), magnetic disks, and/or other types of storage components.Additionally, the non-transitory computer-readable memory 104 may beconfigured to store, among other things, computer readable instructions,one or more look-up tables, the time delay table described below, andany data necessary to compute the orientation outputs of the sensordevice 100 described below.

As stated above, the processor 102 may include any processing componentconfigured to receive and execute instructions (such as from thenon-transitory computer useable memory 104). It is noted that theorientation calculations described herein may be effectuated by theprocessor 102 as software instructions stored on the non-transitorycomputer useable memory 104, as well as by any additional controllerhardware, if present (not shown). In some embodiments, the additionalcontroller hardware may comprise logic gates to perform the softwareinstructions as a hardware implementation. The processor 102 may beconfigured as, but not limited to, a general-purpose microcontroller, anapplication-specific integrated circuit, or a programmable logiccontroller.

The sensor device 100 may be incorporated into larger systems, and maybe able to communicate with external devices and components of suchsystems via input/output hardware (not shown). The input/output hardwaremay include any hardware and/or software for sending and receiving datato an external device, such as an output signal corresponding to anorientation estimation of the sensor device 100. Exemplary input/outputhardware includes, but is not limited to, universal serial bus (USB),FireWire, Thunderbolt, local area network (LAN) port, wireless fidelity(Wi-Fi) card, WiMax card, and/or other hardware for communicating withother networks and/or external devices.

As described in more detail below, each of the one or more gyroscopes106, the one or more accelerometers 108 (if provided), and the one ormore magnetometers 110 (if provided) may be configured to provide asignal to the processor 102 (or other components of the sensor device100) that corresponds with a physical quantity that represents aphysical orientation of the sensor device 100. The signal or data fromthe various sensors 106, 108, 110 may be provided to the processor 102and/or additional controller hardware. For example, the accelerometer108 may be configured to provide a signal/data that corresponds to itsorientation relative to gravity, while the magnetometer 110 may beconfigured to provide a signal/data that corresponds to its orientationrelative to magnetic North, and the gyroscope 106 may be configured toprovide a signal/data that corresponds to its position with respect tox-, y- and z-axes. The accelerometer 108, the gyroscope 106, and themagnetometer 110 may be configured as any proprietary, currentlyavailable, or yet-to-be-developed sensor device. It should be understoodthat the sensor device 100 may include any combination of magnetometers110, accelerometers 108 and/or gyroscopes 106 (or other sensors thatoutput a sensor vector corresponding to orientation).

Referring now to FIGS. 3A and 3B, a method of calculating an orientationof a sensor device 100 including at least one magnetometer 110 isgraphically illustrated in a flowchart 200. Generally, the process isstarted, a reference magnetic field magnitude is initiated, and acurrent magnetic field magnitude from a magnetic field reading generatedby the magnetometer 110 is determined and stored (blocks 202, 204, 206,and 208). It is noted that each magnetic field reading generated by themagnetometer 110 includes both a magnetic field direction and a magneticfield magnitude. Next, a current magnetic field magnitude is compared tothe reference magnetic field magnitude to determine if the difference isgreater than or less than a threshold (i.e., is the current magneticfield magnitude close to the reference field magnitude) (blocks 210,212, 214 and 215). If the difference between the current magnetic fieldmagnitude and the reference magnetic field magnitude is greater than thethreshold, then the trust value of the magnetometer(s) 110 is decreasedat block 215. If the difference between the current magnetic fieldmagnitude and the reference magnetic field magnitude is less than thethreshold and a waiting period has expired, then the trust value isincreased at block 214.

Using the magnetic field readings of the magnetometer(s) 110 and thetrust value, as well as the readings of the gyroscope(s) 106 and theaccelerometer(s) 108, if provided, the orientation of the sensor deviceis computed and provided as an output signal (blocks 216, 218, 220, 222,224, and 226). Decreasing the trust value applied to the magnetometerreduces or eliminates the influence of the magnetic field readings ofthe magnetometer 110 on the output signal corresponding to theorientation of the sensor device 100. When the trust value of themagnetometer is low (e.g., zero), the influence of the accelerometer(s)108 and gyroscope(s) 106, if provided, is increased. In this manner, thedisruption caused by the external magnetic field does not corrupt thecomputed orientation of the sensor device 100.

Details regarding the process depicted the flowchart 200 shown in FIGS.3A and 3B are provided below.

Reference Magnitude

In some embodiments, the reference magnetic field magnitude is obtainedby averaging the magnitudes of a certain number of previous readingsfrom the magnetometer 110. This average should be initialized outside ofsignificant magnetic interference before detection of such interferenceis attempted. The magnitude of the magnetometer reading provides ameasure of the strength of the magnetic field. Because the Earth'smagnetic field is relatively weak in comparison to most interferencemagnetic fields, the absolute difference of the averaged magnetic fieldmagnitude (i.e., reference magnetic field magnitude) and the currentmagnitude field magnitude can indicate whether or not the magnetometer'sreadings are corrupted by an interference magnetic field. By comparingthis absolute difference D when the sensor device 100 is experiencinginterference and when it is not, a suitable threshold ε can bedetermined for the desired application. As an example and not alimitation, ε=0.03. An appropriate difference D between the referencemagnetic field magnitude and the current magnetic field magnitude formost applications may be the absolute difference, although otherdistance metrics could be used.

The process of flowchart 200 starts at block 202, such as when thesensor device 100 is initialized. At block 204, the reference magneticfield magnitude is initialized and determined. This process should becompleted in the absence of interference magnetic fields to achieve anaccurate reference magnetic field magnitude that is representative ofthe Earth's magnetic field. At block 204, several current magnetic fieldmagnitudes may be determined and averaged to calculate the referencemagnetic field magnitude. It is noted that, before implementing theprocess, several parameters should be chosen appropriately for thedesired application. The number of iterations used for initialization ofthe reference magnetic field magnitude, n, should be small enough thatthe start-up process is not too long. However, it also should be longenough to establish an accurate average magnitude for comparison. Theexact value may depend on factors such as the number of measurements persecond the magnetometer will make, the anticipated rate of change inorientation or position, and the type of average that is beingcalculated to compute the reference magnetic field magnitude (i.e. arunning average, a weighted average, and the like). During theinitialization process at block 204, the only calculations beingperformed are the calculation of the current magnitude and the averagemagnitude to determine the reference magnetic field magnitude.

Further with respect to calculating the reference magnetic fieldmagnitude, it may be continuously updated during operation of the sensordevice 100 at block 26. As an example and not a limitation, one way tocalculate the reference magnetic field magnitude, either at block 204 orblock 216, is by the following equation:m _(ref)←∝_(compass) *m _(ref)+(1−∝_(compass))*m;  Eq. (1),where:

-   -   ← is the assignment operator,    -   m_(ref) is the reference magnetic field magnitude,    -   m is the current magnetic field magnitude, and    -   α_(compass) is a predetermined value.

The parameter α_(compass) is used to determine how quickly the referencemagnetic field magnitude may change. In one embodiment, the parameter orα_(compass) ranges in between zero and one, though the formula could beadjusted to accommodate other ranges. The parameter or α_(compass)determines how much memory the reference magnetic field magnitude willhave. If it is close to one, the reference magnetic field magnitude willchange very slowly and stay close to its initialized value longer. If itis close to zero, the value will change very quickly. It is noted thatif the parameter or α_(compass) is given a value of one, the equationwill simplify and the reference magnetic field magnitude will remain thevalue to which it was initialized. Therefore, this value should be setto something less than one; however, it is recommended that the value belarge enough to avoid having the reference magnetic field magnitudeitself corrupted by an interference magnetic field. As a non-limitingexample, one recommended value is 0.97. It should also be noted that thetechnique for calculation during the initialization stage may bedifferent from Eq. (1), but it need not be if an appropriate α_(compass)is chosen. If α_(compass) is chosen to be a lower value duringinitialization, such as 0.9, the reference magnetic field magnitude willbe able to converge quickly.

It is also noted that after initialization (block 204), the techniqueprovided by Eq. (1) has the advantages of computational efficiency andlower memory requirements over calculating the average over a number ofstored previous magnitudes, as well as the advantage of control ofmemory fading over a running average.

After initialization of the reference magnitude at block 204, theprocessor at block 206 receives a current magnetic field magnitude. Insome embodiments, the current magnetic field reading (including bothmagnitude and direction) is stored in a time delay table at block 208,which is described in more detail below.

The process then moves to block 210 where it is determined whether ornot the current magnetic field magnitude is close to the referencemagnetic field magnitude. In other words, it is determined if thecurrent magnetic field magnitude is close to that of the magnitude ofthe Earth's magnetic field at the particular geographical location ofthe sensor device 100. in some embodiments, the difference D, betweenthe magnitude (or similar norm) of the current magnetic field magnitudeof the magnetometer 110, m, and the reference magnetic field magnitude(norm), m_(ref), is compared to an experimentally determined threshold,ε. If D>ε, it is likely that the magnetometer 110 is experiencinginterference. In some embodiments, a variable indicates that D>ε. Onceinterference is detected, the trust level may be adjusted accordingly(i.e., decreased at block 214). The trust level may be adjusted prior toany use of the magnetometer readings to avoid the use of corrupted data.Block 212 illustrates a waiting mechanism that delays when the trustlevel may be increased at block 214. Examples of this waiting mechanismare described below.

Possible Trust Level Adjustments

The methods with which the trust level is adjusted (blocks 214, 215) areindependent of the detection method. One method is to set the trustlevel to a defined minimum trust value at block 215 and to switch itback to a default level (i.e., maximum trust value) after theinterference magnetic field is no longer detected. For instance, if theapplication involves sensing orientation, and there is the possibilityof strong magnetic interference during operation, the minimum trustvalue may be set to zero when a corrupting field is detected. The sensordevice 100 may rely on other sensors (e.g., accelerometer(s) 108 and/orgyroscopes(s) 106) and time propagation at during the time when thetrust level is set to the minimum trust level. When the detection method(e.g., block 210) indicates that the magnetometer 110 has not beencorrupted for a suitable period of time (i.e. a waiting period), thesensor device 100 may switch back to trusting the magnetometer at somechosen default level (i.e., a maximum trust level). The waiting periodmay be provided so that a single false negative will not affect theorientation calculation.

Another method of adjusting the trust level of the magnetometer 110 isto switch to the minimum trust level and to slowly converge back to themaximum trust value over a convergence period. This method may beimplemented in a number of ways. As a non-limiting example one method isto choose a number of consecutive, interference-free iterations toconverge back to the maximum trust level. For each consecutive iterationwithout interference, the trust level of the magnetometer may be raisedusing the following equation providing a convergence period:

$\begin{matrix}{\left. T\leftarrow{T_{\min} + {\left( {1 - \frac{I}{I_{\max}}} \right)*\left( {T_{default} - T_{\min}} \right)}} \right.;} & {{Eq}.\mspace{14mu}(2)}\end{matrix}$where:

-   -   T is the trust value,    -   T_(min) is the minimum trust value,    -   T_(max) is the maximum trust value,    -   I_(max) is a number of consecutive iterations to return the        trust value to the maximum trust value T_(max), and    -   I is a number of iterations remaining to return the trust value        to the maximum trust value T_(max).

It is noted that, in the beginning of the waiting period, I=I_(max) andthat as I converges toward zero, the trust value T converges towardT_(default), which may be the maximum trust value.

It should be understood that other ways to gradually converge the trustvalue back to the default trust value are possible. An alternativetechnique is to make the rate of change in the trust value T increase asthe number of iterations gets closer to I_(max). However, this may notbe necessary for most applications if a suitable waiting period isobserved before the process of increasing trust level begins.

Waiting Period to Leave Interference-Free Mode

There are also many possible ways of determining the waiting mechanismprovided at block 212. In some embodiments, the waiting mechanism couldbe configured as a counter or a variable which acts as a test toindicate when the magnetometer 110 will be, or will begin to be,increased to the default value (i.e., the maximum trust value). As anexample, consider a variable L_(ignore), which is given a value such asone whenever interference is detected, and then slowly decays accordingto an equation, such as:L _(ignore)←∝_(ignore) *L _(ignore)  Eq. (3),where:

-   -   L_(ignore) indicates a current state of the waiting period and        is set to a maximum value when the difference between the        current magnetic field magnitude and the reference magnetic        field magnitude is greater than the threshold, and    -   α_(ignore) determines how quickly L_(ignore) decays.

The variable L_(ignore) will be compared to some fixed value to see ifit has decayed sufficiently to determine that the sensor device 100 isoutside of the interference magnetic field 192. This method may beuseful in some applications, as it provides more control over thewaiting mechanism than a simple counter scheme. It should be understoodthat similar decay equations could be substituted depending on theapplication.

Time Delayed Magnetometer Data

Because the magnetometer's trust level is not adjusted until the giventhreshold is reached or exceeded, disturbances under the threshold canappear in magnetometer data and be fully trusted in final orientationdata. In many use cases, significant disturbances from an interferencemagnetic field under the threshold would appear immediately before asignificant disturbance that is over the threshold. This is the case ifa magnet or other object which can cause a disturbance is suddenlybrought close to the magnetometer, as the disturbances will start underthe threshold, and will quickly rise above the threshold, assuming thethreshold has been set properly to account for objects which cause thatmagnitude of disturbance.

This issue may be accounted for by providing an optional time delaybetween when the current magnetic field magnitude is detected by themagnetometer and when the orientation of the sensor device is computed.This may reduce the affect on disturbances that are close, but under,the threshold from adversely affecting the computed orientation. Thereare many ways to achieve such as time delay. In one non-limitingexample, all magnetometer readings are stored when they are initiallyread either for some number of iterations or some fixed amount of timebefore applying them to the orientation calculation. This givesinterference detection time to detect any disturbances and to properlyadjust the trust level before the magnetometer data is used to calculateany other piece of data. As an example, one method is to store newlyacquired current magnetic field readings into a time delay table (block208), which may be stored in memory 104. Before calculating theorientation using the current magnetic field reading, the time delaytable is accessed for the oldest current magnetic field reading that hasbeen in the time delay table for a required amount of time, such as atime delay threshold (block 218). This delays the use of anymagnetometer readings for the required amount of time, thereby becomingmore resistant to disturbances that are below the threshold.

The process may continue at block 220, where the orientation of thesensor device 100 is calculated using the magnetometer readings and themagnetometer trust value, as well as readings from the one or moregyroscopes 106 and the one or more accelerometers 108, if provided. Anyknown or yet-to-be-developed method of calculating the orientation ofthe sensor device 100 may be utilized. After calculating the orientationof the sensor device 100, an output signal of the orientation isprovided at block 222.

The process continues to block 224, which repeats the process as long asnecessary. The breaking condition indicated at block 224 could be anygiven breaking condition, such as the loop having run for apredetermined amount of time, or no breaking condition at all, in whichcase the loop may continue indefinitely. If the breaking condition atblock 224 occurs, the process ends at block 226, at which point alcalculation stops.

It is to be understood that the preceding detailed description isintended to provide an overview or framework for understanding thenature and character of the subject matter as it is claimed. It will beapparent to those skilled in the art that various modifications andvariations can be made to the embodiments described herein withoutdeparting from the spirit and scope of the present disclosure. Thus, itis intended that the claimed subject matter cover the modifications andvariations of this disclosure provided they come within the scope of theappended claims and their equivalents.

It is noted that terms like “commonly,” when utilized herein, are notintended to limit the scope of the claimed subject matter or to implythat certain features are critical, essential, or even important to thestructure or function of the claimed subject matter. Rather, these termsare merely intended to highlight alternative or additional features thatmay or may not be utilized in a particular embodiment.

The invention claimed is:
 1. A sensor device to measure orientationcomprising: a plurality of sensing devices including a magnetometer andone or more from a group of an accelerometer and a gyroscope, whereinthe magnetometer measures a magnetic field and produces a magnetic fieldreading including at least a magnitude of the magnetic field; aprocessor, wherein the processor is communicatively coupled to theplurality of sensing devices by a communication bus, wherein eachsensing device provides a signal over the communication bus to theprocessor representing a physical orientation of the sensor device; anda non-transitory computer-readable memory storing instructions that,when executed by the processor, cause the processor to: receive acurrent magnetometer reading including at least a current magnetic fieldmagnitude as detected by the magnetometer; detect a presence of thesensor device within an interfering magnetic field based on comparing adifference between the current magnetic field magnitude and a referencemagnetic field magnitude with a threshold; adjust a trust value of themagnetometer such that the trust value is decreased in response to thesensor device being detected within the interfering magnetic field basedon the difference between the current magnetic field magnitude and thereference magnetic field magnitude being greater than or equal to thethreshold; increase the trust value when: the sensor device is detectedoutside the interfering magnetic field based on the difference betweenthe current magnetic field magnitude and the reference magnetic fieldmagnitude being less than the threshold, the trust value is less than amaximum trust value, and following a waiting period beginning when thedifference between the current magnetic field magnitude and thereference magnetic field magnitude was last above the threshold; switchbetween the signals of the plurality of sensing devices to compute anorientation of the sensor device based at least on the trust value,wherein the trust value affects a reliance on magnetic field readings incomputing the orientation of the sensor device; and provide an outputsignal, wherein the output signal indicates the orientation of thesensor device.
 2. The sensor device of claim 1, wherein the waitingperiod is defined by:Lignore <-αignore*Lignore, where: Lignore indicates a current state ofthe waiting period and is set to a maximum value when the differencebetween the current magnetic field magnitude and the reference magneticfield magnitude is greater than the threshold, and αignore determineshow quickly Lignore decays.
 3. The sensor device of claim 1, wherein thetrust value is equal to zero after the trust value is decreased, and thetrust value is equal to one after the trust value is increased.
 4. Thesensor device of claim 1, wherein the trust value ranges from a minimumtrust value to the maximum trust value.
 5. The sensor device of claim 4,wherein the trust value is increased by converging the trust value fromthe minimum trust value to the maximum trust value over a convergenceperiod so long as the difference between the current magnetic fieldmagnitude and the reference magnetic field magnitude is not greater thanthe threshold during the convergence period.
 6. The sensor device ofclaim 5, wherein the minimum trust value is equal to zero and themaximum trust value is equal to one.
 7. The sensor device of claim 1,wherein the trust value is equal to zero after the trust value isdecreased, and the trust value is equal to one when the trust value isincreased.
 8. The sensor device of claim 1, wherein the referencemagnetic field magnitude is determined by:mref<-αcompass*mref+(1−αcompass)*m, where: mref is the referencemagnetic field magnitude, m is the current magnetic field magnitude, andαcompass is a predetermined value.
 9. The sensor device of claim 1,wherein a time delay exists between when the current magnetic fieldreading is detected by the magnetometer and when the currentmagnetometer reading is used to compute the orientation of the sensordevice.
 10. The sensor device of claim 1, wherein the instructionsfurther cause the processor to: receive a plurality of magnetic fieldreadings from the magnetometer; store, in the non-transitorycomputer-readable memory, the plurality of magnetic field readings in atime delay table; and select, as the current magnetic field reading, anoldest magnetic field reading from the plurality of magnetic fieldreadings stored in the time delay table according to a time delaythreshold.
 11. The sensor device of claim 1, wherein the orientation ofthe sensor device is based on one or more outputs from at least one froma group of the accelerometer and the gyroscope.
 12. A sensor device tomeasure orientation comprising: a plurality of sensing devices includinga magnetometer and one or more from a group of an accelerometer and agyroscope, wherein the magnetometer measures a magnetic field andproduces a magnetic field reading including at least a magnitude of themagnetic field; a processor, wherein the processor is communicativelycoupled to the plurality of sensing devices by a communication bus,wherein each sensing device provides a signal over the communication busto the processor representing a physical orientation of the sensordevice; and a non-transitory computer-readable memory storinginstructions that, when executed by the processor, cause the processorto: receive a current magnetometer reading including at least a currentmagnetic field magnitude as detected by the magnetometer; detect apresence of the sensor device within an interfering magnetic field basedon comparing a difference between the current magnetic field magnitudeand a reference magnetic field magnitude with a threshold; adjust atrust value of the magnetometer such that the trust value is decreasedin response to the sensor device being detected within the interferingmagnetic field based on the difference between the current magneticfield magnitude and the reference magnetic field magnitude being greaterthan or equal to the threshold; increase the trust value when: thesensor device is detected outside the interfering magnetic field basedon the difference between the current magnetic field magnitude and thereference magnetic field magnitude being less than the threshold, thetrust value is less than a maximum trust value, and following a waitingperiod beginning when the difference between the current magnetic fieldmagnitude and the reference magnetic field magnitude was last above thethreshold, wherein: the trust value ranges from a minimum trust value tothe maximum trust value, the trust value is increased by converging thetrust value from the minimum trust value to the maximum trust value overa convergence period so long as the difference between the currentmagnetic field magnitude and the reference magnetic field magnitude isnot greater than the threshold during the convergence period, and theconvergence period is defined by:T<-Tmin+(1−I/Imax)*(Tdefault−Tmin), where: T is the trust value, Tmin isthe minimum trust value, Tdefault is the maximum trust value, Imax is anumber of consecutive iterations to return the trust value to themaximum trust value, and I is a number of iterations remaining to returnthe trust value to the maximum trust value; switch between the signalsof the plurality of sensing devices to compute an orientation of thesensor device based at least on the trust value, wherein the trust valueaffects a reliance on magnetic field readings in computing theorientation of the sensor device; and provide an output signal, whereinthe output signal indicates the orientation of the sensor device. 13.The sensor device of claim 12, wherein I=Imax when it is determined thatthe difference between the current magnetic field magnitude and thereference magnetic field magnitude is greater than the threshold, andthe trust value T converges toward the maximum trust value as Iconverges toward zero.
 14. The sensor device of claim 12, wherein theinstructions further cause the processor to: receive a plurality ofmagnetic field readings from the magnetometer; store, in thenon-transitory computer-readable memory, the plurality of magnetic fieldreadings in a time delay table; and select, as the current magneticfield reading, an oldest magnetic field reading from the plurality ofmagnetic field readings stored in the time delay table according to atime delay threshold.
 15. The sensor device of claim 12, wherein theorientation of the sensor device is based on one or more outputs from atleast one from a group of the accelerometer and the gyroscope.
 16. Amethod of computing an orientation of a sensor device comprising aplurality of sensing devices and a processor communicatively coupled tothe plurality of sensing devices by a communication bus, wherein theplurality of sensing devices includes a magnetometer and one or morefrom a group of an accelerometer and a gyroscope with each sensingdevice providing a signal over the communication bus to the processorrepresenting a physical orientation of the sensor device, the methodcomprising: receiving by the processor a plurality of magnetic fieldreadings from the magnetometer, each magnetic field reading comprisingat least a magnetic field magnitude; storing by the processor, in anon-transitory computer-readable memory, the plurality of magnetic fieldreadings in a time delay table; selecting by the processor, as a currentmagnetic field reading, an oldest magnetic field reading from theplurality of magnetic field readings stored in the time delay tableaccording to a time delay threshold; detecting by the processor apresence of the sensor device within an interfering magnetic field basedon comparing a difference between the current magnetic field magnitudeand a reference magnetic field magnitude with a threshold; adjusting bythe processor a trust value of the magnetometer such that the trustvalue is decreased in response to the sensor device being detectedwithin the interfering magnetic field based on the difference betweenthe current magnetic field magnitude and the reference magnetic fieldmagnitude being greater than or equal to the threshold; switchingbetween the signals of the plurality of sensing devices for computing anorientation of the sensor device based at least on the trust value,wherein the trust value affects a reliance on magnetic field readings incomputing the orientation of the sensor device; and providing an outputsignal, wherein the output signal indicates the orientation of thesensor device.
 17. The method of claim 16, further comprising increasingthe trust value when the difference between the current magnetic fieldmagnitude and the reference magnetic field magnitude is less than thethreshold, the trust value is less than a maximum trust value, andfollowing a waiting period beginning when the difference between thecurrent magnetic field magnitude and the reference magnetic fieldmagnitude was last above the threshold.
 18. The method of claim 16,wherein a time delay exists between when the current magnetic fieldreading is detected by the magnetometer and when the currentmagnetometer reading is used to compute the orientation of the sensordevice.